//-----------------------------------------------------------------------------
// Name: DeadHuman.cpp
// Auth: Robert Darty
// Desc: Dead Human Code
//-----------------------------------------------------------------------------

#include "DeadHuman.h"

#include "SharedConstants.h"

#include "corona/corona.h"

#include <GL/glut.h>
#include <math.h>

//-----------------------------------------------------------------------------
// Globals:
//-----------------------------------------------------------------------------
cDeadHuman gDeadHuman;


//-----------------------------------------------------------------------------
// Functions:
//-----------------------------------------------------------------------------
cDeadHuman* GetDeadHuman()
{
	return &gDeadHuman;
}

//-----------------------------------------------------------------------------
// class cBarn:
//-----------------------------------------------------------------------------
cDeadHuman::cDeadHuman() :
	mXPosition(500),
	mZPosition(500),
	mRotate(0)
{

}

cDeadHuman::~cDeadHuman()
{
}

//Move dead human to position
void cDeadHuman::Move(float x, float z)
{
	mXPosition = x;
	mZPosition = z;
}

//rotate dead human
void cDeadHuman::Rotate( float r )
{
	mRotate = r;
}

//Draw dead human
void cDeadHuman::Draw()
{
			
	glPushMatrix();
	{
			glTranslatef(mXPosition, 0.2f, mZPosition);

			float fRotate = -90.0f;
			float fYaw = 0.0f;
			


			glRotatef( fRotate, 1.0f, 0.0f, 0.0f );

		glPushMatrix();

			glRotatef( fYaw-90, 0.0f, 1.0f, 0.0f );
			glBegin(GL_QUADS);

			glColor3f(0.01f, 0.01f, 0.01f);

			glColor3f( 0.6f, 0.3f, 0.3f );

			//left foot
			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.2f, 0, 0 );
			glVertex3f( 0.2f, 0.15f, 0 );
			glVertex3f( 0.2f, 0.15f, 0.2f );
			glVertex3f( 0.2f, 0, 0.2f );

			//left-side
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.2f, 0, 0.2f );
			glVertex3f( 0.2f, 0.15f, 0.2f );
			glVertex3f( -0.1f, 0.15f, 0.2f );
			glVertex3f( -0.1f, 0, 0.2f );
			
			//right side
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.2f, 0, 0 );
			glVertex3f( -0.1f, 0, 0 );
			glVertex3f( -0.1f, 0.15f, 0 );
			glVertex3f( 0.2f, 0.15f, 0 );
			
			//top
			glNormal3f(0.0f,1.0f,0.0f);
			glVertex3f( 0.2f, 0.15f, 0.2f );
			glVertex3f( 0.2f, 0.15f, 0 );
			glVertex3f( -0.1f, 0.15f, 0 );
			glVertex3f( -0.1f, 0.15f, 0.2f );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.1f, 0, 0 );
			glVertex3f( -0.1f, 0, 0.2f );
			glVertex3f( -0.1f, 0.15f, 0.2f );
			glVertex3f( -0.1f, 0.15f, 0 );

			//right foot
			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.2f, 0, 0 );
			glVertex3f( 0.2f, 0, -0.2f );
			glVertex3f( 0.2f, 0.15f, -0.2f );
			glVertex3f( 0.2f, 0.15f, 0 );

			//left side
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.2f, 0, 0 );
			glVertex3f( 0.2f, 0.15f, 0 );
			glVertex3f( -0.1f, 0.15f, 0 );
			glVertex3f( -0.1f, 0, 0 );

			//right side
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.2f, 0, -0.2f );
			glVertex3f( -0.1f, 0, -0.2f );
			glVertex3f( -0.1f, 0.15f, -0.2f );
			glVertex3f( 0.2f, 0.15f, -0.2f );

			//top
			glNormal3f(0.0f,1.0f,0.0f);
			glVertex3f( 0.2f, 0.15f, -0.2f );
			glVertex3f( -0.1f, 0.15f, -0.2f );
			glVertex3f( -0.1f, 0.15f, 0 );
			glVertex3f( 0.2f, 0.15f, 0 );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.1f, 0, 0 );
			glVertex3f( -0.1f, 0.15f, 0 );
			glVertex3f( -0.1f, 0.15f, -0.2f );
			glVertex3f( -0.1f, 0, -0.2f );

			glColor3f(0.86f, 0.72f, 0.53f);

			//neck
			//left side
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.1f, 1.5f, 0.1f );
			glVertex3f( 0.1f, 1.65f, 0.1f );
			glVertex3f( -0.1f, 1.65f, 0.1f );
			glVertex3f( -0.1f, 1.5f, 0.1f );

			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.1f, 1.5f, -0.1f );
			glVertex3f( 0.1f, 1.65f, -0.1f );
			glVertex3f( 0.1f, 1.65f, 0.1f );
			glVertex3f( 0.1f, 1.5f, 0.1f );

			//right side
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.1f, 1.5f, -0.1f );
			glVertex3f( -0.1f, 1.5f, -0.1f );
			glVertex3f( -0.1f, 1.65f, -0.1f );
			glVertex3f( 0.1f, 1.65f, -0.1f );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.1f, 1.5f, -0.1f );
			glVertex3f( -0.1f, 1.5f, 0.1f );
			glVertex3f( -0.1f, 1.65f, 0.1f );
			glVertex3f( -0.1f, 1.65f, -0.1f );

			glColor3fv(kColorBlack);

			//body
			//left
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.2f, 1.0f, 0.2f );
			glVertex3f( 0.2f, 1.5f, 0.2f );
			glVertex3f( -0.2f, 1.5f, 0.2f );
			glVertex3f( -0.2f, 1.0f, 0.2f );

			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.2f, 1.0f, -0.2f );
			glVertex3f( 0.2f, 1.5f, -0.2f );
			glVertex3f( 0.2f, 1.5f, 0.2f );
			glVertex3f( 0.2f, 1.0f, 0.2f );

			//right
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.2f, 1.0f, -0.2f );
			glVertex3f( -0.2f, 1.0f, -0.2f );
			glVertex3f( -0.2f, 1.5f, -0.2f );
			glVertex3f( 0.2f, 1.5f, -0.2f );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.2f, 1.0f, -0.2f );
			glVertex3f( -0.2f, 1.0f, 0.2f );
			glVertex3f( -0.2f, 1.5f, 0.2f );
			glVertex3f( -0.2f, 1.5f, -0.2f );

			//top
			glNormal3f(0.0f, 1.0f,0.0f);
			glVertex3f( 0.2f, 1.5f, 0.2f );
			glVertex3f( 0.2f, 1.5f, -0.2f );
			glVertex3f( -0.2f, 1.5f, -0.2f );
			glVertex3f( -0.2f, 1.5f, 0.2f );

			//left arm
			//left side
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.1f, 1.0f, 0.3f );
			glVertex3f( 0.1f, 1.5f, 0.3f );
			glVertex3f( -0.1f, 1.5f, 0.3f );
			glVertex3f( -0.1f, 1.0f, 0.3f );

			//right side
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.1f, 1.0f, 0.2f );
			glVertex3f( -0.1f, 1.0f, 0.2f );
			glVertex3f( -0.1f, 1.5f, 0.2f );
			glVertex3f( 0.1f, 1.5f, 0.2f );

			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.1f, 1.0f, 0.2f );
			glVertex3f( 0.1f, 1.5f, 0.2f );
			glVertex3f( 0.1f, 1.5f, 0.3f );
			glVertex3f( 0.1f, 1.0f, 0.3f );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.1f, 1.0f, 0.2f );
			glVertex3f( -0.1f, 1.0f, 0.3f );
			glVertex3f( -0.1f, 1.5f, 0.3f );
			glVertex3f( -0.1f, 1.5f, 0.2f );

			//top
			glNormal3f(0.0f, 1.0f, 0.0f);
			glVertex3f( -0.1f, 1.5f, 0.3f );
			glVertex3f( 0.1f, 1.5f, 0.3f );
			glVertex3f( 0.1f, 1.5f, 0.2f );
			glVertex3f( -0.1f, 1.5f, 0.2f );

			//right arm
			//right side
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.1f, 1.0f, -0.3f );
			glVertex3f( -0.1f, 1.0f, -0.3f );
			glVertex3f( -0.1f, 1.5f, -0.3f );
			glVertex3f( 0.1f, 1.5f, -0.3f );

			//left side
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.1f, 1.0f, -0.2f );
			glVertex3f( 0.1f, 1.5f, -0.2f );
			glVertex3f( -0.1f, 1.5f, -0.2f );
			glVertex3f( -0.1f, 1.0f, -0.2f );

			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.1f, 1.0f, -0.3f );
			glVertex3f( 0.1f, 1.5f, -0.3f );
			glVertex3f( 0.1f, 1.5f, -0.2f );
			glVertex3f( 0.1f, 1.0f, -0.2f );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.1f, 1.0f, -0.3f );
			glVertex3f( -0.1f, 1.0f, -0.2f );
			glVertex3f( -0.1f, 1.5f, -0.2f );
			glVertex3f( -0.1f, 1.5f, -0.3f );

			//top
			glNormal3f(0.0f,1.0f,0.0f);
			glVertex3f( 0.1f, 1.5f, -0.2f );
			glVertex3f( 0.1f, 1.5f, -0.3f );
			glVertex3f( -0.1f, 1.5f, -0.3f );
			glVertex3f( -0.1f, 1.5f, -0.2f );

			glColor3f(0.3f, 0.3f, 1.0f);

			//hips
			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.2f, 0.8f, -0.2f );
			glVertex3f( 0.2f, 1.0f, -0.2f );
			glVertex3f( 0.2f, 1.0f, 0.2f );
			glVertex3f( 0.2f, 0.8f, 0.2f );

			//left
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.2f, 0.8f, 0.2f );
			glVertex3f( 0.2f, 1.0f, 0.2f );
			glVertex3f( -0.2f, 1.0f, 0.2f );
			glVertex3f( -0.2f, 0.8f, 0.2f );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.2f, 0.8f, -0.2f );
			glVertex3f( -0.2f, 0.8f, 0.2f );
			glVertex3f( -0.2f, 1.0f, 0.2f );
			glVertex3f( -0.2f, 1.0f, -0.2f );

			//right
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.2f, 0.8f, -0.2f );
			glVertex3f( -0.2f, 0.8f, -0.2f );
			glVertex3f( -0.2f, 1.0f, -0.2f );
			glVertex3f( 0.2f, 1.0f, -0.2f );


			//legs 
			//left leg
			//front
			glNormal3f(0.974391f, 0.22486f, 0.0f);
			glVertex3f( 0.05f, 0.15f, 0 );
			glVertex3f( 0.2f, 0.8f, 0 );
			glVertex3f( 0.2f, 0.8f, 0.2f );
			glVertex3f( 0.05f, 0.15f, 0.2f );

			//left
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.05f, 0.15f, 0.2f );
			glVertex3f( 0.2f, 0.8f, 0.2f );
			glVertex3f( -0.2f, 0.8f, 0.2f );
			glVertex3f( -0.1f, 0.15f, 0.2f );

			//right
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.05f, 0.15f, 0 );
			glVertex3f( -0.1f, 0.15f, 0 );
			glVertex3f( -0.2f, 0.8f, 0 );
			glVertex3f( 0.2f, 0.8f, 0 );

			//back
			glNormal3f(-0.988372f,-0.152057f,0.0f);
			glVertex3f( -0.1f, 0.15f, 0 );
			glVertex3f( -0.1f, 0.15f, 0.2f );
			glVertex3f( -0.2f, 0.8f, 0.2f );
			glVertex3f( -0.2f, 0.8f, 0 );

			//right leg
			//front
			glNormal3f(0.974391f, -0.22486f, 0.0f);
			glVertex3f( 0.05f, 0.15f, 0 );
			glVertex3f( 0.05f, 0.15f, -0.2f );
			glVertex3f( 0.2f, 0.8f, -0.2f );
			glVertex3f( 0.2f, 0.8f, 0 );

			//back
			glNormal3f(-0.988372f,-0.152057f,0.0f);
			glVertex3f( -0.1f, 0.15f, 0 );
			glVertex3f( -0.2f, 0.8f, 0 );
			glVertex3f( -0.2f, 0.8f, -0.2f );
			glVertex3f( -0.1f, 0.15f, -0.2f );

			//right
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.05f, 0.15f, -0.2f );
			glVertex3f( -0.1f, 0.15f, -0.2f );
			glVertex3f( -0.2f, 0.8f, -0.2f );
			glVertex3f( 0.2f, 0.8f, -0.2f );

			//left
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.05f, 0.15f, 0 );
			glVertex3f( 0.2f, 0.8f, 0 );
			glVertex3f( -0.2f, 0.8f, 0 );
			glVertex3f( -0.1f, 0.15f, 0 );

			glColor3f(0.86f, 0.72f, 0.53f);

			//left hand
			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.1f, 0.8f, 0.2f );
			glVertex3f( 0.1f, 1.0f, 0.2f );
			glVertex3f( 0.1f, 1.0f, 0.3f );
			glVertex3f( 0.1f, 0.8f, 0.3f );

			//left side
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.1f, 0.8f, 0.3f );
			glVertex3f( 0.1f, 1.0f, 0.3f );
			glVertex3f( -0.1f, 1.0f, 0.3f );
			glVertex3f( -0.1f, 0.8f, 0.3f );

			//right side
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.1f, 0.8f, 0.2f );
			glVertex3f( 0.1f, 1.0f, 0.2f );
			glVertex3f( -0.1f, 1.0f, 0.2f );
			glVertex3f( -0.1f, 0.8f, 0.2f );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.1f, 0.8f, 0.2f );
			glVertex3f( -0.1f, 0.8f, 0.3f );
			glVertex3f( -0.1f, 1.0f, 0.3f );
			glVertex3f( -0.1f, 1.0f, 0.2f );

			//bottom
			glNormal3f(0.0f,-1.0f,0.0f);
			glVertex3f( 0.1f, 0.8f, 0.3f );
			glVertex3f( -0.1f, 0.8f, 0.3f );
			glVertex3f( -0.1f, 0.8f, 0.2f );
			glVertex3f( 0.1f, 0.8f, 0.2f );

			//right hand
			//front
			glNormal3f(1.0f,0.0f,0.0f);
			glVertex3f( 0.1f, 0.8f, -0.3f );
			glVertex3f( 0.1f, 1.0f, -0.3f );
			glVertex3f( 0.1f, 1.0f, -0.2f );
			glVertex3f( 0.1f, 0.8f, -0.2f );

			//back
			glNormal3f(-1.0f,0.0f,0.0f);
			glVertex3f( -0.1f, 0.8f, -0.3f );
			glVertex3f( -0.1f, 0.8f, -0.2f );
			glVertex3f( -0.1f, 1.0f, -0.2f );
			glVertex3f( -0.1f, 1.0f, -0.3f );

			//left side
			glNormal3f(0.0f,0.0f,1.0f);
			glVertex3f( 0.1f, 0.8f, -0.2f );
			glVertex3f( 0.1f, 1.0f, -0.2f );
			glVertex3f( -0.1f, 1.0f, -0.2f );
			glVertex3f( -0.1f, 0.8f, -0.2f );

			//right side
			glNormal3f(0.0f,0.0f,-1.0f);
			glVertex3f( 0.1f, 0.8f, -0.3f );
			glVertex3f( -0.1f, 0.8f, -0.3f );
			glVertex3f( -0.1f, 1.0f, -0.3f );
			glVertex3f( 0.1f, 1.0f, -0.3f );

			//bottom
			glNormal3f(0.0f,-1.0f,0.0f);
			glVertex3f( 0.1f, 0.8f, -0.2f );
			glVertex3f( -0.1f, 0.8f, -0.2f );
			glVertex3f( -0.1f, 0.8f, -0.3f );
			glVertex3f( 0.1f, 0.8f, -0.3f );

			glEnd();

			//head
			glPushMatrix();

			glTranslatef( 0, 1.8f, 0 );
			glutSolidSphere( 0.2f, 100, 100 );
			glPopMatrix();

			//eyes
			glColor3f(0.0f, 0.0f, 0.0f);
			glPushMatrix();
			glTranslatef (0.18f, 1.85f, 0.05f);
			glutSolidSphere(0.035 , 5, 5);
			glPopMatrix();

			glPushMatrix();
			glTranslatef (0.18f, 1.85f, -0.05f);
			glutSolidSphere(0.035 , 5, 5);
			glPopMatrix();

			//nose
			glColor3f(0.86f, 0.72f, 0.53f);
			glPushMatrix();
			glTranslatef(0.2f, 1.8f, 0);
			glutSolidSphere(0.035 , 5, 5);
			glPopMatrix();

			glColor3f(0.95f, 1.0f, 0.95f);
			glPushMatrix();
			glTranslatef(0.2f, 1.8f, 0);
			//glutWireSphere( 0.035, 5, 5 );
			glPopMatrix();
		glPopMatrix();
		}
		glPopMatrix();

}